<template>
  <!-- 头部 -->
  <div class="itemMusicTop">
    <img :src="playlist.coverImgUrl" alt="" class="bgimg" />
    <div class="itemLeft">
      <svg class="icon" aria-hidden="true" @click="$router.go(-1)">
        <use xlink:href="#icon-zuojiantou"></use>
      </svg>
      <span>歌单</span>
    </div>
    <div class="itemRight">
      <svg class="icon" aria-hidden="true" @click="$router.push('/search')">
        <use xlink:href="#icon-sousuo"></use>
      </svg>
      <van-popover
        v-model:show="showPopover"
        :actions="actions"
        placement="bottom-end"
      >
        <template #reference>
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-youcecaidan"></use>
          </svg>
        </template>
      </van-popover>
    </div>
  </div>
  <!-- 头部作者 -->
  <div class="itemMusicTopContent">
    <img :src="playlist.coverImgUrl" alt="" class="imgstyle" />
    <div class="musicDetailRight">
      <span style="color: #fff">{{ playlist.name }}</span>
      <div class="author">
        <img :src="creator.backgroundUrl" alt="" class="authorImg" />
        <span class="authorName">&nbsp;{{ creator.nickname }}</span>
      </div>
      <span class="description">{{ playlist.description }}</span>
    </div>
    <!-- 播放量 -->
    <div class="playcount">
      <svg
        class="icon"
        aria-hidden="true"
        style="width: 0.35rem; vertical-align: -7px"
      >
        <use xlink:href="#icon-24gl-play"></use>
      </svg>
      {{ playcount(playlist.playCount) }}
    </div>
  </div>
  <!-- 头部功能 -->
  <div class="function">
    <div class="some">
      <svg class="icon" aria-hidden="true">
        <use xlink:href="#icon-pinglun"></use>
      </svg>
      <span>{{ playlist.commentCount }}</span>
    </div>
    <div class="some">
      <svg class="icon" aria-hidden="true">
        <use xlink:href="#icon-fenxiang"></use>
      </svg>
      <span>{{ playlist.shareCount }}</span>
    </div>
    <div class="some">
      <svg class="icon" aria-hidden="true">
        <use xlink:href="#icon-xiazai"></use>
      </svg>
      <span>下载</span>
    </div>
    <div class="some">
      <svg class="icon" aria-hidden="true">
        <use xlink:href="#icon-duoxuan"></use>
      </svg>
      <span>多选</span>
    </div>
  </div>
</template>

<script>
import { computed, ref } from "vue";

export default {
  props: ["playlist"],
  setup(props) {
    //创作者数据
    let creator = computed(() => {
      return props.playlist.creator || {};
    });

    const showPopover = ref(false);
    const actions = [
      { text: "更改歌曲排序", icon: "sort" },
      { text: "清空下载文件", icon: "delete" },
      { text: "举报", icon: "warning" },
    ];

    //方法  计算播放量
    function playcount(num) {
      let newnum = (num / 10000).toFixed(1) + "万";
      return newnum;
    }

    return { creator, playcount, actions, showPopover };
  },
};
</script>

<style lang="less" scoped>
.itemMusicTop {
  position: relative;
  width: 100%;
  height: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .itemLeft,
  .itemRight {
    width: 25%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0.2rem;
    span {
      font-size: 0.4rem;
      color: #fff;
    }
    .icon {
      fill: #fff; //填充颜色
    }
  }
  .bgimg {
    width: 100%;
    height: 11rem;
    position: fixed;
    z-index: -1;
    filter: blur(30px);
  }
}
.itemMusicTopContent {
  margin-top: 0.2rem;
  display: flex;
  justify-content: space-around;
  height: 3.04rem;
  position: relative;
  .imgstyle {
    width: 40%;
    border-radius: 0.4rem;
    margin-left: 0.2rem;
  }
  .musicDetailRight {
    margin: 0 0.2rem 0 0.4rem;
    .author {
      margin-top: 0.2rem;
      .authorName {
        vertical-align: 0.3rem;
        font-size: 12px;
        color: rgb(139, 135, 135);
      }
      .authorImg {
        width: 0.8rem;
        border-radius: 50%;
        margin-right: 0.1rem;
      }
    }
    .description {
      display: block;
      color: rgb(139, 135, 135);
      height: 1.2rem;
      overflow: auto;
    }
  }
  .playcount {
    position: absolute;
    top: 0;
    left: 1.5rem;
    opacity: 0.6;
  }
}
.function {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-top: 0.5rem;
  .some {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    opacity: 0.8;
    font-size: 0.25rem;
    .icon {
      fill: #fff;
    }
  }
}
</style>